package com.example.targetOffer.controller;

import com.example.targetOffer.service.LinkedListService;
import com.example.targetOffer.struct.ListNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping(value = "/LinkedList")
public class LinkedListController {
    private static final Logger log = LoggerFactory.getLogger(LinkedListController.class);

    @Autowired
    private LinkedListService listService;

    /**
     * 输入一个链表的头节点，从尾到头反过来返回每个节点的值（用数组返回）
     * https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/
     */
    @RequestMapping(value = "reverseLink", method = RequestMethod.GET)
    public void reverseLink() {
        ListNode node = new ListNode(1);
        int[] array = listService.reversePrint(node);
        log.info(Arrays.toString(array));
    }

    /**
     * Review
     * 反转链表注意再回顾下图解视频
     * https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/
     */
}
